import React, { PureComponent } from 'react';
import { Modal, List, InputItem, WhiteSpace, Button, WingBlank, Menu, ActivityIndicator, SearchBar, Accordion } from 'antd-mobile';
import { connect } from 'dva';
import ast from './index.less';
import { setCookie } from '../../utils/auth'
import { createForm, formShape } from 'rc-form';
import { Divider } from 'antd';
const PlaceHolder = ({ className = '', ...restProps }) => (
  <div className={`${className} placeholder`} {...restProps}>Block</div>
);
class Achievements extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      initData: '',
      show: false,
      selectedTab: 'redTab',
      hidden: false,
      fullScreen: false
    };
  }
  componentWillMount() {
    this.props.dispatch({ type: "achievements/loadCultivateScoreList", payload: {
      rows:100,
      Order:'asc',
      isStu:1,
      page:1
    } })
}
  handleClick = (e) => {
    e.preventDefault(); // Fix event propagation on Android
    this.setState({
      show: !this.state.show,
    });
  }

  onMaskClick = () => {
    this.setState({
      show: false,
    });
  }

  render() {
    const { initData, show } = this.state;
    const loadingEl = (
      <div style={{ width: '100%', height: document.documentElement.clientHeight * 0.6, display: 'flex', justifyContent: 'center' }}>
        <ActivityIndicator size="large" />
      </div>
    );
    return (
      <div className={show ? ast.menu_active : ''}>
        <SearchBar placeholder="请输入课程名称" ref={ref => this.autoFocusInst = ref} />
        <WhiteSpace />
        <Accordion defaultActiveKey="0" className={ast.my_accordion} onChange={this.onChange}>
        {this.props.performance.length == 0 ? null :
                      this.props.performance.map((s,key) => {
                        return (<Accordion.Panel key={key} className={ast.Panel} header={
                          <div className={ast.Panel_title}>
                            <img src={require('../../assets/icon_05.png')} style={{ padding: '20px' }} />
                              
                            <p>{s.courseName}</p>
                            <p style={{ margin:'0px 10px' , float:'right' }}>分数：<b>{`${s.endScore}分`}</b></p>
                          </div>
                        }>
                          <ul>
                            <li>{`课程编号：${s.courseNum}`}</li>
                            <li>{`学分：${s.credit}分`}</li>
                            <li>{`课程属性：${s.coursePropertyCode == 0 ? '公共课' : '专业课' }`}</li>
                            <li>{`课程类别：${s.courseTypeCode  == 0 ? '必修课': s.courseTypeCode  == 1 ?'选修课': s.courseTypeCode  == 2 ? '不修': s.courseTypeCode }`}</li>
                            <li>{`课程性质：${s.isDegree == 32 ? '学位课': '非学位课'}`}</li>
                          </ul>
                        </Accordion.Panel>)
                      })
                    }
          
          
        </Accordion>
      </div>

    );
  }
}
function mapStateToProps(state) {
  return {
    performance: state.achievements.timetable
  }
}
export default connect(mapStateToProps)(Achievements);
